﻿using System;
using System.Reflection;
using Dsl.Ped.Common.Helpers;

namespace Dsl.Ped.Common.Extensions
{
    /// <summary>
    /// Extensions of <see cref="Assembly"/>
    /// </summary>
    public static class AssemblyExtension
    {
        /// <summary>
        /// Get the version string of assembly in a format 'Version: [long_number]'
        /// </summary>
        /// <param name="assembly">
        /// The assembly.
        /// </param>
        /// <returns>Long version string </returns>
        public static string GetLongVersionString(this Assembly assembly)
        {
            return AssemblyHelper.GetLongVersionString(assembly);
        }

        /// <summary>
        /// Get the version string of assembly in a format 'Version: [short_number]'
        /// </summary>
        /// <param name="assembly">The assembly</param>
        /// <param name="length">The length of the version string</param>
        /// <returns>Short version string</returns>
        public static string GetShortVersionString(this Assembly assembly, int length = 2)
        {
            return AssemblyHelper.GetShortVersionString(assembly, length);
        }

        /// <summary>
        /// Get the full <see cref="Version"/> of the <see cref="Assembly"/>
        /// </summary>
        /// <param name="assembly">The <see cref="Assembly"/> which version we are interested in</param>
        /// <returns>Full <see cref="Version"/> of <see cref="Assembly"/></returns>
        public static Version GetLongVersion(this Assembly assembly)
        {
            return AssemblyHelper.GetLongVersion(assembly);
        }

        /// <summary>
        /// Get the short <see cref="Assembly"/> version in a <see cref="string"/> format
        /// </summary>
        /// <param name="assembly">
        /// The <see cref="Assembly"/> which version we are interested in
        /// </param>
        /// <param name="length">The length of the version string</param>
        /// <returns>Short version of <see cref="Assembly"/> in a string format</returns>
        public static string GetShortVersion(this Assembly assembly, int length = 2)
        {
            return AssemblyHelper.GetShortVersion(assembly, length);
        }
    }
}
